package opera;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOpreation{

    @Override
    public void work(BookList bookList) {
        System.out.println("请输入你要查找的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int a = bookList.getUsedSize();
        for (int i = 0; i < a; i++) {
            Book book = bookList.getBooks(i);
            if (book.getName().equals(name)){
                System.out.println(book);
                return;
            }
        }
        System.out.println("对不起，没有找到你要寻找的图书。");
    }
}
